const request = require('../utils/request')

/**
 * 获取订单预览数据
 * @returns {Promise<unknown>}
 */
export const orderPreview = () =>request.get('/api/orders/preview')

/**
 * 提交订单
 * @param data
 * @returns {Promise<unknown>}
 */
export const addOrder=(data) =>request.post('/api/orders',data)

/**
 * 订单详情
 * @param id
 * @returns {Promise<unknown>}
 */
export const getOrderInfo = (id) =>request.get('/api/orders/' + id + '?include=orderDetails.goods,address')

/**
 * 订单列表
 * @param data
 * @return {Promise<unknown>}
 */
export const getOrderList = (data) =>request.get('/api/orders',data,false)
/**
 * 确认收货
 * @param id
 * @return {Promise<unknown>}
 */
export const confirmReceipt = (id) =>request.patch('/api/orders/'+ id + '/confirm')
/**
 * 评论商品
 * @param id   订单id
 * @param data
 * @return {Promise<unknown>}
 */
export const comment = (id,data) =>request.post('/api/orders/'+ id +'/comment',data)